<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>query</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon">
    <link href="/static/css/reset.css" rel="stylesheet">
    <!-- Bootstrap3.3.5 CSS -->
    <link href="/static/css/bootstrap.min.css" rel="stylesheet"><link rel="stylesheet" href="/static/css/query.css">
  </head>
  <body>
    <div class="container">
      <h2>电子证件存证</h2>
      <div id="query">
        <div class="left">
          <form action="/query" method="post" name="queryForm">
              <p>
              <div class="headImg">
                  <div class="uploadImg">
                      <input type="file" name="" value="上传照片" id="file">
                      +
                      <img src="" alt="">
                  </div>
              </div>
              </p>

              <a href="/index">返回首页</a>
              <a href="/queryPage2">电子证件核验</a>
          </form>
        </div>

      </div>
      <
    </div>
  </body>
  <script type="text/javascript" src="/static/js/jquery.min.js"></script>
  <script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
  <script type="text/javascript">
    $(function() {
        // 上传图片
        $('#file').unbind('change').bind('change',function() {
            event.stopPropagation();
            uploadFile('img');
            return;
        });
        // 头像图片
        var artImg;
        function uploadFile(type) {
            event.stopPropagation();
            let formData = new FormData();
            if( type == "img"){
                formData.append('file', $('#file')[0].files[0]);
            }
            $.ajax({
                url: '/upload',
                type: 'POST',
                cache: false,
                data: formData,
                processData: false,
                dataType: "json",
                contentType: false
            }).done(function (res) {
                if (res.error == "0") {
                    if( type == "img"){
                        // $('.uploadImg img').attr('src',res.result.path);
                        // $('#photo').val(res.result.path)
                        $('#photo').val('')
                        alert("存证成功！交易ID：" +res.result.transactionID)
                    }
                } else {
                    alert("存证失败！" + res.result.msg)
                }ß
            }).fail(function (res) { });
        }
         })
  </script>
</html>
